﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

public partial class SystemManage_UsersList : System.Web.UI.Page
{
    protected void Page_PreInit(object sender, EventArgs e)
    {
        Page.Theme = BLL.Common.GetWSMThemes();
    }
    private int pageIndex
    {
        get
        {
            if (Request.Params["page"] == null)
                return 1;
            else
            {
                return int.Parse(Request.Params["page"]);
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Check.CheckPermission("100400");
        if (!IsPostBack)
        {
            Bind();
        }
    }
    private void Bind()
    {
        int pageCount, Counts;
        List<Model.USERS> l = new BLL.USERS().GetList(20, pageIndex, "USERS_CODE", false, " AND USERS_CODE!='ADMIN' ", out pageCount, out Counts);
        USERSListControl1.Bind(l);
        PageControl1.Bind(pageIndex, 20, Counts, Request.Url.ToString(), "page");
    }
    public void Add()
    {
        if (Check.CheckPermission("100400", "00001"))
        {
            Response.Redirect("UserEdit.aspx");
        }
        else
        {
            Share.Alert(this.Page,"无权操作"); return;
        }
    }
    public void Update()
    {
        if (Check.CheckPermission("100400", "00002"))
        {
            List<string> s = USERSListControl1.Selected;
            if (s.Count > 0)
            {
                Response.Redirect("UserEdit.aspx?usercode=" + s[0]);
            }
            else
            {
                //MessageBox.Show("s");
                Page.RegisterStartupScript("StartUp", "<script language=javascript>alert('请选择一条需要编辑的记录')</script>");
                //Share.Alert(this.Page,"请选择操作行"); 
            }
        }
        else
        {
            Share.Alert(this.Page,"无权操作"); return;
        }
    }
    public void Delete()
    {
        if (Check.CheckPermission("100400", "00003"))
        {
            List<string> s = USERSListControl1.Selected;
            new BLL.USERS().Delete(s);
            Share.InsertLog("100400", "00003");
            Response.Redirect("UsersList.aspx");
        }
        else
        {
            Share.Alert(this.Page,"无权操作"); return;
        }
    }
}
